﻿// Defines a header for any widget that needs it.
// It contains an icon, title (and tools ???)

define([
    'Wjs/ui/widgets/foundation/ViewHashContainer',
    'Wjs/ui/widgets/foundation/Icon',
    'Wjs/ui/widgets/foundation/Label',
    'Wjs/ui/widgets/tools/ToolBar'
],
function () {
    'use strict';

    return Wjs.define({

        type: 'Header',

        internal: {

            base: Wjs.getType('ViewHashContainer'),

            initialize: function () {

                this.addClass('wjs-header wjs-display-flex');

                this.addSection('icon',

                    Wjs.new('Icon')
                );

                this.addSection('title',

                    Wjs.new('Label')
                        .addClass('wjs-title wjs-display-flex-1')
                );

                this.addSection('tools',

                    Wjs.new('ToolBar')
                        .addClass('wjs-header-toolbar')
                );
            }
        },

        getIcon: function() {

            return this.getSection('icon');
        },

        getTitle: function() {

            return this.getSection('title');
        },

        getTools: function() {

            return this.getSection('tools');
        },

        setText: function (text) {

            this.getTitle().setText(text);

            return this;
        },

        setHtml: function (html) {

            this.getTitle().setHtml(html);

            return this;
        },

        setIconClass: function(iconClass) {

            this.getIcon().setIconClass(iconClass);

            return this;
        },

        addTool: function (tool) {

            this.getTools().addItem(tool);

            return this;
        }

    });

});